package com.link2room.optimus.controller.inside;


import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.optimus.dto.param.base.MarketingBaseParamDto;
import com.link2room.optimus.dto.param.inside.BookStockInsideParamDto;
import com.link2room.common.util.DateUtil;
import com.link2room.optimus.facade.IMarketingFacadeService;
import com.link2room.optimus.dto.result.base.BookStockDto;
import com.link2room.optimus.dto.result.base.L2REverydayPriceAndStockDto;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by sss on 2016/9/20.
 */
@Api(tags = "活动明细")
@RestController
@RequestMapping("/in/MarketingDetails")
public class MarketingDetailInsideController {
    @Resource
    private IMarketingFacadeService marketingFacadeService;

    @RequestMapping(value = "/BookStock",method= RequestMethod.GET)
    public BaseResultDto bookStocks(
            @RequestParam(value = "lhotelCode" ,required = false) String lhotelCode,
            @RequestParam(value = "mcdCode" ,required = false) String mcdCode,
            @RequestParam(value = "checkInDatetime" ,required = true) String checkInDatetime,
            @RequestParam(value = "checkOutDatetime" ,required = true) String checkOutDatetime,
            @RequestParam(value = "rmNum" ,required = true) Integer rmNum,
            @RequestParam(value = "memberLevel" ,required = false) String memberLevel,
            @RequestParam(value = "pbChannel" ,required = true) String pbChannel,
            @RequestParam(value = "isUsePoint" ,required = false) String isUsePoint
    ) throws Exception {
        BookStockInsideParamDto bookStockInsideParamDto =new BookStockInsideParamDto();
        bookStockInsideParamDto.setLhotelCode(lhotelCode);
        bookStockInsideParamDto.setMcdCode(mcdCode);
        bookStockInsideParamDto.setCheckInDatetime(DateUtil.format(DateUtil.parseDateWevFormat(checkInDatetime),DateUtil.newFormat));
        bookStockInsideParamDto.setCheckOutDatetime(DateUtil.format(DateUtil.parseDateWevFormat(checkOutDatetime),DateUtil.newFormat));
        bookStockInsideParamDto.setRmNum(rmNum);
        bookStockInsideParamDto.setPbChannel(pbChannel);
        bookStockInsideParamDto.setMemberLevel(memberLevel);
        bookStockInsideParamDto.setIsUsePoint(isUsePoint);
        BookStockDto bookStockDto = marketingFacadeService.getMarketingDetail(bookStockInsideParamDto);
        BaseResultDto l2rRs=new BaseResultDto();
        l2rRs.setResultCode(0);
        l2rRs.setResultInfo(bookStockDto);
        return l2rRs;
    }

    @RequestMapping(value = "/MarketingDetailDates",method= RequestMethod.GET)
    public BaseResultDto getMarketingDetailDates(
            @RequestParam(value = "lhotelCode" ) String lhotelCode,
            @RequestParam(value = "mcdCode") String mcdCode,
            @RequestParam(value = "pbChannel") String pbChannel,
            @RequestParam(value = "startDatetime") String startDatetime,
            @RequestParam(value = "endDatetime") String endDatetime,
            @RequestParam(value = "memberLevel" ,required = false) String memberLevel
    ) throws Exception {
        MarketingBaseParamDto marketingBaseParamDto =new MarketingBaseParamDto();
        marketingBaseParamDto.setLhotelCode(lhotelCode);
        marketingBaseParamDto.setMcdCode(mcdCode);
        marketingBaseParamDto.setStartDatetime(startDatetime);
        marketingBaseParamDto.setEndDatetime(endDatetime);
        marketingBaseParamDto.setPbChannel(pbChannel);
        marketingBaseParamDto.setMemberLevel(memberLevel);
        List<L2REverydayPriceAndStockDto> l2REverydayPriceAndStockDtoList = marketingFacadeService.getMarketingDetailDataList(marketingBaseParamDto);
        BaseResultDto l2rRs=new BaseResultDto();
        l2rRs.setResultCode(0);
        l2rRs.setListToQueryResult(l2REverydayPriceAndStockDtoList);
        return l2rRs;
    }
}
